# FreeRDP: A Remote Desktop Protocol Implementation
# FreeRDP Sample Server cmake build script
#
# Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 2.8)

project(Sample)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++20 -fPIC -Wall")

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

find_package(FreeRDP 2 REQUIRED)
find_package(WinPR REQUIRED)
# set(QT_MAJOR_VERSION 6)
# set(QT_MIN_VERSION "6.4.0")
# message(STATUS "QT_MAJOR_VERSION: ${QT_MAJOR_VERSION}")
# message(STATUS "QT_MIN_VERSION: ${QT_MIN_VERSION}")
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED Core Gui Network Widgets)


set(MODULE_NAME "sfreerdp-server")
set(MODULE_PREFIX "FREERDP_SERVER_SAMPLE")

set(${MODULE_PREFIX}_SRCS
  main.cpp
  rdpserver.cpp
  rdpserver.h
  rdpsession.cpp
  rdpsession.h
  sslgen.cpp
  sslgen.h
	sfreerdp.cpp
	sfreerdp.h
	sf_encomsp.c
	sf_encomsp.h
   )

add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})

set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-server2)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp)

target_include_directories(${MODULE_NAME} PRIVATE
  ${FreeRDP_INCLUDE_DIR} ${WinPR_INCLUDE_DIR} ${FreeRDP_Server_INCLUDE_DIR}
)
message(STATUS "FreeRDP_LIBRARIES_DIR:${FreeRDP_LIBRARIES_DIR}")
target_link_directories(${MODULE_NAME} PRIVATE
  ${FreeRDP_LIBRARIES_DIR} ${FreeRDP_Server_LIBRARIES_DIR}
)

target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS} 
Qt${QT_MAJOR_VERSION}::Widgets
Qt${QT_MAJOR_VERSION}::Core
Qt${QT_MAJOR_VERSION}::Network
Qt${QT_MAJOR_VERSION}::Gui
)
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT server)
if (WITH_DEBUG_SYMBOLS AND MSVC)
    install(FILES ${CMAKE_PDB_BINARY_DIR}/${MODULE_NAME}.pdb DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT symbols)
endif()

set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/Sample")
